//
//  TaskManager+IsDone.m
//  gong
//
//  Created by echo on 14-1-13.
//  Copyright (c) 2014年 echo. All rights reserved.
//

#import "TaskManager+IsDone.h"
#import "GameManager.h"
#import "Constants.h"
#import "AutoRemoveMessageView.h"

@implementation TaskManager (IsDone)

- (void)monitorTaskIsDone
{
    if ([_currentTask.triggerPlace isEqualToString:[GameManager sharedInstance].currentPlaceName]) {
        if ([_currentTask.name isEqualToString:@"去乐技坊"]) {
            if ([[GameManager sharedInstance].currentPlaceName isEqualToString:@"乐技坊"]) {
                [self notifyTaskIsDone];
            }
        } else if ([_currentTask.name isEqualToString:@"第一次拜见太后"]) {
            if ([[GameManager sharedInstance].currentPlaceName isEqualToString:@"太后宫"]) {
//                [self notifyTaskIsDone];
            }
        }
    }
}

- (void)whenTaskIsDone:(NSNotification*)notification
{
//    NSDictionary *userInfo = notification.userInfo;
    [self notifyTaskIsDone];
}

- (void)notifyTaskIsDone
{
    NSString *taskName = _currentTask.name;
    _currentTask = [self getNextTask];
    NSString *msg;
    
    if (![TaskManager sharedInstance].isLastTask) {
        msg = [NSString stringWithFormat:@"当前任务%@完成,奖励%i个玉石。下一个任务是%@", taskName, _currentTask.awardJade,  _currentTask.name];
    } else {
        msg = [NSString stringWithFormat:@"当前任务%@完成,奖励%i个玉石。", taskName, _currentTask.awardJade];
    }
    
    NSLog(@"当前任务:%@完成", taskName);
    NSLog(@"下一个任务是：%@", _currentTask.name);

//    [[[UIAlertView alloc] initWithTitle:@"" message:msg delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil] show];
    
    NSString *awardMsg;
    awardMsg = [NSString stringWithFormat:@"当前任务%@完成,奖励%i个玉石。", taskName, _currentTask.awardJade];

    [[GameManager sharedInstance] showAward:awardMsg];
}
@end
